<template>
  <div class="flex-center">
    <Form :model="roomInfo" label-position="top" :label-width="100">
      <FormItem label="用户名">
        <Input v-model="roomInfo.userId"></Input>
      </FormItem>
      <FormItem label="房间号">
        <Input v-model.number="roomInfo.roomId"></Input>
      </FormItem>
      <FormItem>
        <Button @click="loginRoom">进入房间</Button>
      </FormItem>
    </Form>
  </div>
</template>

<script>
import { mapActions } from "vuex";

export default {
  data() {
    return {
      roomInfo: {
        userId: "user-wangqingteng",
        roomId: 55737
      }
    };
  },
  computed: {},
  methods: {
    ...mapActions("live", ["updateRoomInfo"]),
    loginRoom() {
      this.updateRoomInfo({ ...this.roomInfo });
      this.$router.push({
        name: "Live",
        params: {
          id: this.roomInfo.roomId
        }
      });
    }
  },
  created() {}
};
</script>

<style lang="scss">
.flex-center {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-content: center;
}
</style>
